package com.ztf0337.mycurriculumdesign.service;

import android.content.Context;

import com.ztf0337.mycurriculumdesign.dao.RentDao;
import com.ztf0337.mycurriculumdesign.database.AppDatabase;
import com.ztf0337.mycurriculumdesign.entity.RentedParkingSpace;

import java.util.List;

public class RentService {

    private final RentDao rentDao;

    public RentService(Context context) {
        AppDatabase db = AppDatabase.getInstance(context);
        this.rentDao = db.rentDao();
    }

    public long insert(RentedParkingSpace rentedParkingSpace) {
        return rentDao.insert(rentedParkingSpace);
    }

    public void delete(RentedParkingSpace rentedParkingSpace) {
        rentDao.delete(rentedParkingSpace);
    }

    public RentedParkingSpace getRentById(Long id) {
        return rentDao.getRentById(id);
    }

    public List<RentedParkingSpace> getRentsByUserId(Long id) {
        return rentDao.getRentsByUserId(id);
    }

    public List<RentedParkingSpace> searchRents(String content, Long user_id) {
        return rentDao.searchRents(content,user_id);
    }
}
